/**
 * @param {string} word
 * @param {character} ch
 * @return {string}
*/
var reversePrefix = function(word, ch) {
  let index = word.indexOf(ch);
  if(index == -1) return word;
  let arr = word.split("");
  return arr.slice(0, index + 1).reverse().join("") + arr.slice(index + 1, arr.length).join('');
};
let word = "abcdefd", ch = "d";
console.log(reversePrefix(word, ch));
word = "xyxzxe", ch = "z";
console.log(reversePrefix(word, ch));
word = "abcd", ch = "z";
console.log(reversePrefix(word, ch));
